package cn.xiaopengstack.domain.activity.service.quota.rule.chain;

import cn.xiaopengstack.types.utils.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * @author jiangyangang
 */
@Slf4j
public abstract class AbstractActionChain implements IActionChain{

    protected IActionChain nextChain;

    @Override
    public IActionChain appendChain(IActionChain chain) {
        this.nextChain = chain;
        return this.nextChain;
    }

    @Override
    public IActionChain next() {
        if (Objects.isNull(nextChain)) {
            return SpringContextUtil.getBean(DefaultActionChain.class);
        }

        return nextChain;
    }

}
